package com.beiwei.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.beiwei.auto.mode.Company;
import com.beiwei.auto.mode.CompanyExample;
import com.beiwei.mapper.VCompanyMapper;

@Service
public class CompanyService {
	@Autowired
	private VCompanyMapper companyMapper;

	/**
	 * 根据companyId查询company
	 */
	public Company findCompanyByCompanyId(Integer companyId) throws Exception {
		return companyMapper.selectByPrimaryKey(companyId);
	}

	/**
	 * 查询出所有的公司
	 */
	public List<Company> findAllCompany() throws Exception {
		CompanyExample example = new CompanyExample();
		CompanyExample.Criteria criteria = example.createCriteria();
		criteria.andDelFlagEqualTo(0);

		return companyMapper.selectByExample(example);
	}

	/**
	 * 新增公司..将该公司id设置如company
	 */
	public boolean getCompanyIdByAddCompany(Company company) throws Exception {
		if(companyMapper.getCompanyIdByAddCompany(company) == 1){
			return true;
		}
		return false;
	}

}
